import GrpcCreator  from '../utils/service'
import { GreeterClient } from '../grpc/HelloworldServiceClientPb'
import { HelloRequest, HelloErrRequest, HelloMapRequest } from '../grpc/helloworld_pb'

const backendUrl = "/api";
const helloClient = new GrpcCreator(GreeterClient, backendUrl)

export function sayHello(data) {
  return helloClient.sendRequest(HelloRequest, 'sayHello', data)
}

export function errRequest(data) {
  return helloClient.sendRequest(HelloErrRequest, 'sayErr', data)
}

export function timeoutRequest() {
  return helloClient.sendRequest(HelloMapRequest, 'sayMap', {name: 'timeout'})
}

export function sayMap(data) {
  return helloClient.sendRequest(HelloMapRequest, 'sayMap', data)
}
